<template>
  <div class="app-container">
    <el-row>
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-col :span="21">
          <el-form-item label="统计月份" prop="month">
            <el-date-picker
              v-model="queryParams.month"
              type="month"
              :max-date="maxMonth"
              format="yyyy-MM"
              @change="changeMonth"
              placeholder="请选择统计月份">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="运营人员" prop="operator">
            <el-cascader
              v-model="queryParams.deptUser"
              :options="userOptions"
              :normalizer="user_normalizer"
              @change="handleChangeUser"
              clearable
              placeholder="请选择运营人员"></el-cascader>
          </el-form-item>
          <el-form-item label="店铺名称" prop="cusname">
            <el-input v-model.trim="queryParams.cusname" placeholder="请填写店铺名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </el-col>
      </el-form>
    </el-row>

    <el-table v-loading="loading" :data="dataList" border>
      <el-table-column label="序号" align="center" type="index" width="50" fixed></el-table-column>
      <el-table-column label="操作" width="100" align="center" v-if="name=='admin'" fixed>
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
        </template>
      </el-table-column>
      <el-table-column label="店铺名称" prop="cusname" width="180" :show-overflow-tooltip="true" align="center" fixed/>
      <el-table-column label="开始操作日期" prop="operStartDate" width="120" :show-overflow-tooltip="true" align="center" fixed/>
      <el-table-column label="暂停/流失日期" prop="operEndDate" width="120" :show-overflow-tooltip="true" align="center" fixed/>
      <el-table-column
        v-for="head in headerList"
        :key="head.prop"
        :prop="head.prop"
        :label="head.label"
        align="center">
        <template slot-scope="scope">
          <el-tag type="danger" v-if="scope.row[head.prop]==='0'">无操作</el-tag>
          <el-tag type="success" v-if="scope.row[head.prop]==='1'">正常</el-tag>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 编辑数据 -->
    <el-dialog :title="title" :visible.sync="showDialog" width="600px" :close-on-click-modal="false" append-to-body>
      <span style="font-weight: bold">当前月份：{{shopTjForm.month}}</span>
      <el-table v-loading="loading" :data="shopTjForm.operationDatas" border  style="margin-top: 20px">
        <el-table-column label="序号" align="center" type="index" width="50" fixed></el-table-column>
        <el-table-column label="日期" prop="date" width="180" :show-overflow-tooltip="true" align="center"/>
        <el-table-column label="是否有操作记录" prop="value" :show-overflow-tooltip="true" align="center">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.value"
                       active-text="是"
                       inactive-text="否"
                      v-if="scope.row.state=='1'"></el-switch>
            <span v-if="scope.row.state=='0'">未开始，无需操作</span>
            <span v-if="scope.row.state=='2'">已暂停/流失，无需操作</span>
          </template>
        </el-table-column>
<!--        <el-table-column label="是否有操作记录" prop="state" :show-overflow-tooltip="true" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <el-tag type="success" v-if="scope.row.state==='1'">正常</el-tag>-->
<!--            <el-tag type="danger" v-if="scope.row.state==='2'">暂停/流失</el-tag>-->
<!--            <el-tag type="info" v-if="scope.row.state==='0'">未开始</el-tag>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-prevent-re-click>确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { selectAllDeptUser } from '@/api/system/user'
import { compareDate, firstDayOfLastMonth } from '@/utils/ruoyi'
import {
  initOperationSummary,
  insertOperationSummary,
  selectOperationSummaryList,
  updateOperationSummary
} from '@/api/tj/operation'
import moment from 'moment'
import { mapGetters } from 'vuex'
import { selectDateList } from '@/api/system/date'

export default {
  name: 'OperationSummary',
  data() {
    return {
      // 是否显示加载动画
      loading: false,
      // 查询条件
      queryParams: {
        month: '',
        operator: '',
        cusname: '',
        deptUser: [],
        pageNum: 1,
        pageSize: 10
      },
      // 最大统计日期
      maxMonth: '',
      // 用户
      userOptions: [],
      // 表头
      headerList: [],
      // 数据列表
      dataList: [],
      // 总数
      total: 0,
      // 弹出窗口标题
      title: '',
      // 是否显示弹出窗口
      showDialog: false,
      // 店铺操作记录统计表单
      shopTjForm: {
        id: '',
        // 统计月份
        month: '',
        // 关联店铺id
        customId: '',
        // 开始操作日期
        startDate: undefined,
        // 暂停/流失日期
        endDate: undefined,
        // 每日数据
        operationDatas: [],
      },
      // 日期列表
      dateList: []
    }
  },
  computed: {
    ...mapGetters([
      'userid',
      'name',
      'roles'
    ]),
    // 月份天数
    daysOfMonth() {
      let date = new Date(this.queryParams.month)
      return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate()
    }
  },
  watch: {
    // 'queryParams.month'(newVal, oldVal){
    //   this.getMonthDateList(newVal)
    // }
  },
  mounted() {
  },
  created() {
    // 查询组织及用户
    this.selectDeptUserTree()
    // 获取默认的统计月份
    this.getLastMonth()
    // // 初始化表头
    this.initTableHead()
    // 初始化统计数据
    this.initData()
    // 默认执行查询
    this.getList()
  },
  methods: {
    // 查询组织及用户
    selectDeptUserTree(){
      selectAllDeptUser().then(response => {
        this.userOptions = this.handleTree(response.data, "userId");
      })
    },
    // 转换为标准结构
    user_normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.userId,
        label: node.nickName,
        children: node.children
      }
    },
    // 切换运营人员
    handleChangeUser() {
      this.queryParams.operator = this.queryParams.deptUser[this.queryParams.deptUser.length - 1]
    },
    // 获取当前月份的上一个月
    getLastMonth() {
      this.queryParams.month = firstDayOfLastMonth()
      this.maxMonth = this.queryParams.month
    },
    // 初始化统计数据
    initData() {
      const month = moment(this.queryParams.month).format('yyyy-MM')
      initOperationSummary(month)
    },
    // 查询
    handleQuery() {
      this.getList()
    },
    // 查询统计数据
    getList() {
      const params = {}
      params.month = moment(this.queryParams.month).format('yyyyMM')
      params.cusname = this.queryParams.cusname
      params.userId = this.queryParams.operator
      this.loading = true
      selectOperationSummaryList(params).then(response => {
        if(response.code === 200) {
          this.initTableHead()
          this.dataList = response.rows
          this.total = response.rows.length
        }
        this.loading = false
      }).catch(err=>{
        this.loading = false
      })
    },
    // 初始化表头
    initTableHead() {
      let ls = []
      for(let i = 0; i < this.daysOfMonth; i++) {
        const h = {}
        h.label1 = (i + 1) + '号'
        h.label2 = '（' + this.getWeek(moment(this.queryParams.month).format('yyyy-MM') + '-' + (i + 1)) + '）'
        h.label = (i + 1) + '号\n' + '（' + this.getWeek(moment(this.queryParams.month).format('yyyy-MM') + '-' + (i + 1)) + '）'
        h.prop = 'd' + (i + 1)
        ls.push(h)
      }

      this.headerList = ls
    },
    // 切换月份
    changeMonth() {
      //this.getMonthDateList(this.queryParams.month)
      this.initTableHead()
      this.getList()
    },
    // 获取日期是星期几
    getWeek(dateStr) {
      let weeks = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
      let date = new Date(dateStr);
      let weekIndex = date.getDay();

      return weeks[weekIndex]
    },
    // 编辑
    handleUpdate(rowObj) {
      let dataList = []
      for(let i = 1; i <= this.daysOfMonth; i++){
        const obj = {}
        obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-' + i;
        if(i == 1){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-01';
          obj.value = rowObj.d1 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 2){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-02';
          obj.value = rowObj.d2 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 3){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-03';
          obj.value = rowObj.d3 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 4){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-04';
          obj.value = rowObj.d4 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 5){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-05';
          obj.value = rowObj.d5 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 6){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-06';
          obj.value = rowObj.d6 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 7){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-07';
          obj.value = rowObj.d7 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 8){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-08';
          obj.value = rowObj.d8 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 9){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-09';
          obj.value = rowObj.d9 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 10){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-10';
          obj.value = rowObj.d10 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 11){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-11';
          obj.value = rowObj.d11 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 12){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-12';
          obj.value = rowObj.d12 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 13){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-13';
          obj.value = rowObj.d13 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 14){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-14';
          obj.value = rowObj.d14 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 15){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-15';
          obj.value = rowObj.d15 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 16){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-16';
          obj.value = rowObj.d16 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 17){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-17';
          obj.value = rowObj.d17 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 18){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-18';
          obj.value = rowObj.d18 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 19){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-19';
          obj.value = rowObj.d19 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 20){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-20';
          obj.value = rowObj.d20 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 21){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-21';
          obj.value = rowObj.d21 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 22){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-22';
          obj.value = rowObj.d22 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 23){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-23';
          obj.value = rowObj.d23 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 24){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-24';
          obj.value = rowObj.d24 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 25){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-25';
          obj.value = rowObj.d25 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 26){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-26';
          obj.value = rowObj.d26 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 27){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-27';
          obj.value = rowObj.d27 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 28){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-28';
          obj.value = rowObj.d28 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 29){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-29';
          obj.value = rowObj.d29 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 30){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-30';
          obj.value = rowObj.d30 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        else if(i == 31){
          obj.date = moment(this.queryParams.month).format('yyyy-MM') + '-31';
          obj.value = rowObj.d31 != '1' ? false : true
          if(compareDate(rowObj.operStartDate, obj.date)){
            obj.state = '0' // 未开始操作
          }else if(rowObj.operEndDate == null || compareDate(rowObj.operEndDate, obj.date)){
            obj.state = '1' // 正常
          }else{
            obj.state = '2' // 已暂停或流失
          }
        }
        dataList.push(obj)
      }
      this.shopTjForm.id = rowObj.id
      this.shopTjForm.customId = rowObj.customId
      this.shopTjForm.month = moment(this.queryParams.month).format('yyyy年MM月')
      this.shopTjForm.startDate = rowObj.operStartDate
      this.shopTjForm.endDate = rowObj.operEndDate
      this.shopTjForm.operationDatas = dataList

      this.title = '编辑数据'
      this.showDialog = true
    },
    // 提交表单
    submitForm() {
      const obj = {}
      obj.id = this.shopTjForm.id
      obj.month = this.shopTjForm.month.replace('年', '').replace('月', '')
      obj.customId = this.shopTjForm.customId
      this.shopTjForm.operationDatas.forEach(item => {
        if(item.date.split('-')[2] == '01'){
          obj.d1 = item.value ? '1' : '0'
          obj.state1 = item.state
        }
        else if(item.date.split('-')[2] == '02'){
          obj.d2 = item.value ? '1' : '0'
          obj.state2 = item.state
        }
        else if(item.date.split('-')[2] == '03'){
          obj.d3 = item.value ? '1' : '0'
          obj.state3 = item.state
        }
        else if(item.date.split('-')[2] == '04'){
          obj.d4 = item.value ? '1' : '0'
          obj.state4 = item.state
        }
        else if(item.date.split('-')[2] == '05'){
          obj.d5 = item.value ? '1' : '0'
          obj.state5 = item.state
        }
        else if(item.date.split('-')[2] == '06'){
          obj.d6 = item.value ? '1' : '0'
          obj.state6 = item.state
        }
        else if(item.date.split('-')[2] == '07'){
          obj.d7 = item.value ? '1' : '0'
          obj.state7 = item.state
        }
        else if(item.date.split('-')[2] == '08'){
          obj.d8 = item.value ? '1' : '0'
          obj.state8 = item.state
        }
        else if(item.date.split('-')[2] == '09'){
          obj.d9 = item.value ? '1' : '0'
          obj.state9 = item.state
        }
        else if(item.date.split('-')[2] == '10'){
          obj.d10 = item.value ? '1' : '0'
          obj.state10 = item.state
        }
        else if(item.date.split('-')[2] == '11'){
          obj.d11 = item.value ? '1' : '0'
          obj.state11 = item.state
        }
        else if(item.date.split('-')[2] == '12'){
          obj.d12 = item.value ? '1' : '0'
          obj.state12 = item.state
        }
        else if(item.date.split('-')[2] == '13'){
          obj.d13 = item.value ? '1' : '0'
          obj.state13 = item.state
        }
        else if(item.date.split('-')[2] == '14'){
          obj.d14 = item.value ? '1' : '0'
          obj.state14 = item.state
        }
        else if(item.date.split('-')[2] == '15'){
          obj.d15 = item.value ? '1' : '0'
          obj.state15 = item.state
        }
        else if(item.date.split('-')[2] == '16'){
          obj.d16 = item.value ? '1' : '0'
          obj.state16 = item.state
        }
        else if(item.date.split('-')[2] == '17'){
          obj.d17 = item.value ? '1' : '0'
          obj.state17 = item.state
        }
        else if(item.date.split('-')[2] == '18'){
          obj.d18 = item.value ? '1' : '0'
          obj.state18 = item.state
        }
        else if(item.date.split('-')[2] == '19'){
          obj.d19 = item.value ? '1' : '0'
          obj.state19 = item.state
        }
        else if(item.date.split('-')[2] == '20'){
          obj.d20 = item.value ? '1' : '0'
          obj.state20 = item.state
        }
        else if(item.date.split('-')[2] == '21'){
          obj.d21 = item.value ? '1' : '0'
          obj.state21 = item.state
        }
        else if(item.date.split('-')[2] == '22'){
          obj.d22 = item.value ? '1' : '0'
          obj.state22 = item.state
        }
        else if(item.date.split('-')[2] == '23'){
          obj.d23 = item.value ? '1' : '0'
          obj.state23 = item.state
        }
        else if(item.date.split('-')[2] == '24'){
          obj.d24 = item.value ? '1' : '0'
          obj.state24 = item.state
        }
        else if(item.date.split('-')[2] == '25'){
          obj.d25 = item.value ? '1' : '0'
          obj.state25 = item.state
        }
        else if(item.date.split('-')[2] == '26'){
          obj.d26 = item.value ? '1' : '0'
          obj.state26 = item.state
        }
        else if(item.date.split('-')[2] == '27'){
          obj.d27 = item.value ? '1' : '0'
          obj.state27 = item.state
        }
        else if(item.date.split('-')[2] == '28'){
          obj.d28 = item.value ? '1' : '0'
          obj.state28 = item.state
        }
        else if(item.date.split('-')[2] == '29'){
          obj.d29 = item.value ? '1' : '0'
          obj.state29 = item.state
        }
        else if(item.date.split('-')[2] == '30'){
          obj.d30 = item.value ? '1' : '0'
          obj.state30 = item.state
        }
        else if(item.date.split('-')[2] == '31'){
          obj.d31 = item.value ? '1' : '0'
          obj.state31 = item.state
        }
      })
      console.log('提交数据：' + JSON.stringify(obj))
      updateOperationSummary(obj).then(response => {
        this.$message.success('修改成功！')
        this.showDialog = false
        this.getList()
      })
    },
    // 关闭编辑窗口
    cancel() {
      this.showDialog = false
    },
    // 获取月度的日期列表
    getMonthDateList(newDate){
      const yearOrMonth = moment(newDate).format('yyyy-MM').toString()
      selectDateList(yearOrMonth).then(response => {
        this.dateList = response.data
        console.log('日期列表：' + JSON.stringify(this.dateList))
      })
    }
  }
}
</script>

<style scoped lang="scss">
/deep/ .el-table .cell {
  white-space: pre-wrap;   /*这是重点。文本换行*/
}

.cell {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
